package net.riaspace.zendAmfDs
{	
	import mx.rpc.AsyncToken;
	import mx.rpc.remoting.mxml.RemoteObject;

	public dynamic class Service 
	{
		private var _remoteObject:RemoteObject = null;
		
		public function Service(remoteObject:RemoteObject = null, defaultResultHandler:Function = null)
		{
			_remoteObject = remoteObject;
		}
		
		public function query(queryName:String, queryParameters:Array = null, resultHandler:Function = null, faultHandler:Function = null):void
		{
			var asyncToken:AsyncToken = _remoteObject.query(queryName, queryParameters);
			execute(asyncToken, resultHandler, faultHandler);		
		}


		public function execute(asyncToken:AsyncToken, resultHandler:Function = null, faultHandler:Function = null):void
		{
			var responder:Responder = new Responder(resultHandler, faultHandler);
			asyncToken.addResponder(responder);	
		}

		[Bindable]		
		public function get remoteObject():RemoteObject
		{
			return _remoteObject;
		}
		
		public function set remoteObject(remoteObject:RemoteObject):void
		{
			_remoteObject = remoteObject;
		}
	}	
}